import React, { Component } from 'react'
import PropTypes from 'prop-types'

import Item from '../Item'

export class ItemList extends Component {

    static propTypes = {
        todos: PropTypes.array.isRequired,
        updateTodo: PropTypes.func.isRequired,
        deleteTodo: PropTypes.func.isRequired
    }

    render() {
        // console.info(this.props.todos)
        const {todos, updateTodo, deleteTodo} = this.props
        return (
           <ul className="list-group">
            {
                todos.map(todo => <Item key={todo.id} {...todo} updateTodo={updateTodo} deleteTodo={deleteTodo}/>)
            }
           </ul>
        )
    }
}

export default ItemList
